// services/encryptionService.js
const bcrypt = require('bcryptjs');

// 加密密码
const hashPassword = async (password) => {
  const salt = await bcrypt.genSalt(10); // 生成盐
  const hashedPassword = await bcrypt.hash(String(password), salt); // 对密码进行哈希
  return hashedPassword;
};

// 验证密码
const verifyPassword = async (password, hashedPassword) => {
  return await bcrypt.compare(password, hashedPassword); // 比较输入的密码和存储的哈希密码
 
};
module.exports = { hashPassword, verifyPassword };
